package com.gpjcjl.ui;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.viewpager.widget.ViewPager;

import com.google.android.material.tabs.TabLayout;
import com.gpjcjl.BaseActivity;
import com.gpjcjl.R;
import com.gpjcjl.adapter.ViewPagerAdapter;
import com.gpjcjl.ui.fragment.FragmentHisTab1;
import com.gpjcjl.ui.fragment.FragmentHisTab2;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

public class HistoryActivity extends BaseActivity {

    @BindView(R.id.tabLayout)
    TabLayout tabLayout;
    @BindView(R.id.viewPager)
    ViewPager viewPager;

    private List<String> tabTitles = new ArrayList<>();

    public static void startIntent(Context context) {
        Intent it = new Intent(context, HistoryActivity.class);
        context.startActivity(it);
    }

    @Override
    protected int getContentView() {
        return R.layout.activity_history;
    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        tabTitles.add("待上传");
        tabTitles.add("已上传");
        List<Fragment> fragments = new ArrayList<>();
        fragments.add(FragmentHisTab1.newInstance());
        fragments.add(FragmentHisTab2.newInstance());
        viewPager.setAdapter(new ViewPagerAdapter(getSupportFragmentManager(), fragments, tabTitles));
        viewPager.setOffscreenPageLimit(fragments.size());
        tabLayout.setupWithViewPager(viewPager);
    }
}
